#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>

int main()
{
    int fd = open("test.txt",O_RDONLY);
    if(fd == -1){
        perror("open");
        return  1;
    }
    char buffer1[100];
    char buffer2[100];
    struct iovec iov[2];
    iov[0].iov_base = buffer1;
    iov[0].iov_len = sizeof(buffer1);
    iov[1].iov_base = buffer2;
    iov[1].iov_len == sizeof(buffer2);
    ssize_t bytes_read = readv(fd,iov,2);
    if(bytes_read ==  -1){
        perror("readv");
        close(fd);
        return 1;
    }

    //处理读取到的数据，这里简单打印
    buffer1[bytes_read <sizeof(buffer1) ? bytes_read:sizeof(buffer1)-1] = '\0';
    buffer2[bytes_read - (bytes_read < sizeof(buffer1)? bytes_read : sizeof(buffer1)) < sizeof(buffer2)? bytes_read - (bytes_read < sizeof(buffer1)? bytes_read : sizeof(buffer1)) : sizeof(buffer2)-1] = '\0';
    printf("Data in buffer1: %s\n",buffer1);
    printf("Data in buffer2: %s\n",buffer2);
    close(fd);
    return 0;                                              
}                       